package com.esaheki.flashcards.supportModel;

import com.esaheki.flashcards.classes.*;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class CardTableModel extends AbstractTableModel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5916213466368368808L;
	
	private ArrayList<Card> list = null;
	
	public CardTableModel(ArrayList<Card> cardlist) {
		this.list = cardlist;
	}

	@Override
	public int getColumnCount() {
		return 3;
	}

	@Override
	public int getRowCount() {
		return list.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Card card = list.get(rowIndex);
		switch(columnIndex) {
		case 0:
			return card.getFront();
		case 1:
			return card.getBack();
		case 2:
			return card.getScore();
		}
		return null;
	}
	
	public String getColumnName(int columnIndex) {
		switch(columnIndex) {
		case 0:
			return "Front";
		case 1:
			return "Back";
		case 2:
			return "Score";
		}
		return null;
		
	}

}
